package Model;

import java.util.Random;
import java.util.concurrent.Callable;

public class MyCallable implements Callable<Double> {
	int nSteps;
	Double Drift;
	Double St;
	Double S;
	Double Sum;
	Double vSqrdt;
	int z;
	Double X;

	MyCallable(int nSteps, Double Drift,Double St,Double S,Double vSqrdt,int z,Double X) {
		Sum=0.0;
		this.nSteps=nSteps;
		this.Drift=Drift;
		this.vSqrdt=vSqrdt;
		this.z=z;
		this.X=X;
		this.S=S;
		this.St=St;

	}

	public Double getSum() {
		return Sum;
	}

	public void setSum(Double sum) {
		Sum = sum;
	}



	@Override
	public Double call() throws Exception {
		Random rand = new Random();
		St=S;
		Double step1=0.0,step2=0.0,step3=0.0;
		for (int j = 1; j <=nSteps; j++) {
			step1=Drift + vSqrdt * rand.nextGaussian();
			step2= Math.exp(step1);
			St = St *step2;
		}
		Sum = Math.max(z * (St - X), 0);
		return Sum;
	}
} 